#!/usr/bin/python3

import threading
import time

class MyThread(threading.Thread):
    def __init__(self, threadID, name, counter):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.counter = counter
    
    def run(self):
        print("Start thread : " + self.name)
        print_counter(self.name, self.counter, 5)
        print("Exit thread : " + self.name)

def print_counter(threadName, delay, counter):
    while counter:
        print("{} : {}".format(threadName, counter))
        counter -= 1
        time.sleep(delay)

th1 = MyThread(1, "Thread1", 1)
th2 = MyThread(2, "Thread2", 2)

th1.start()
th2.start()
th1.join()
th2.join()

print("Exit the main thread.")